# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=rspet
pkgver=263.de4356e
pkgrel=3
groups=('blackarch' 'blackarch-exploitation' 'blackarch-backdoor'
        'blackarch-dos')
pkgdesc='A Python based reverse shell equipped with functionalities that assist in a post exploitation scenario.'
arch=('any')
url='https://github.com/panagiks/RSPET'
license=('MIT')
depends=('python2' 'python2-flask' 'python2-flask-cors')
makedepends=('git' 'python2-pip')
source=("$pkgname::git+https://github.com/panagiks/RSPET.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i "s|pip.main|#pip.main|g" setup.py

  python2 setup.py
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "${pkgdir}/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "${pkgdir}/usr/share/licenses/$pkgname/LICENSE"

  rm *.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname"

  cat > "$pkgdir/usr/bin/$pkgname-client" << EOF
#!/bin/sh
cd /usr/share/$pkgname/Client/
exec python2 ${pkgname}_client.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname-client"

  cat > "$pkgdir/usr/bin/$pkgname-server" << EOF
#!/bin/sh

cd /usr/share/$pkgname/Server/
exec python2 ${pkgname}_server.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname-server"
}

